//
//  FeedbackViewController.m
//  QT
//
//  Created by 甘世清 on 2025/1/7.
//

#import "FeedbackViewController.h"

@interface FeedbackViewController ()
@property (nonatomic , strong) FSTextView * fsTextView;
@end

@implementation FeedbackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.zx_navTitle = SQNSLocalString(@"反馈");
    WS(weakSelf);
    [self zx_setRightBtnWithText:SQNSLocalString(@"提交") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
        [weakSelf SQ_fankui];
    }];
}

- (void)SQ_UIViewForSelfView{
    [self.view addSubview:self.fsTextView];
    [self.fsTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.zx_navBar.mas_bottom).offset(20);
        make.centerX.equalTo(self.view);
        make.width.mas_equalTo(SCREEN_WIDETH-40);
        make.height.mas_equalTo(140);
    }];
}

-(void)SQ_fankui{
    if (![self.fsTextView.formatText isNotEmpty]) {
        [YJProgressHUD showMsgWithoutView:SQNSLocalString(@"内容不能为空")];
        return;
    }
    [self.view endEditing:YES];
    WS(weakSelf);
    NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
    [dic setObject:self.fsTextView.formatText forKey:@"content"];
    [HttpTool post:@"feedback/save" paramDic:dic successBlock:^(BaseModel * _Nonnull httpModel) {
        [YJProgressHUD showMsgWithoutView:SQNSLocalString(@"反馈成功")];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [weakSelf SQ_popViewVC];
        });
    } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
        [YJProgressHUD showMsgWithoutView:httpModel.message];
    }];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}
-(FSTextView*)fsTextView{
    if (!_fsTextView) {
        _fsTextView = [FSTextView textView];
        _fsTextView.font = FONT_MEDIUM(14);
        _fsTextView.textColor = SQColor333333;
        _fsTextView.placeholder =SQNSLocalString(@"请详细的描述一下您遇到的困难~");
        _fsTextView.placeholderColor = SQColor999999;
        _fsTextView.backgroundColor = SQColorF1F1F1;
        _fsTextView.maxLength = 200;
        _fsTextView.layer.cornerRadius = 10;
        _fsTextView.layer.masksToBounds = YES;
       
    }
    return _fsTextView;
}


@end
